import { NoDblClickDirective } from './directives/no-dbl-click.directive';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
import {
  MatIconModule,
  MatMenuModule,
  MatButtonModule,
  MatSliderModule,
  MatDialogModule,
  MatCheckboxModule,
  MatRadioModule,
  MatFormFieldModule,
  MatSelectModule,
  MatProgressSpinnerModule,
  MatTreeModule,
   MatTooltipModule
} from '@angular/material';

import { NumberCardComponent } from './components/number-card/number-card.component';
import { PaginationComponent } from './components/pagination/pagination.component';
import { CheckboxComponent } from './components/checkbox/checkbox.component';

import { SafePipe } from './pipes/safe.pipe';
import { RangePipe } from './pipes/range.pipe';

import { DataTableComponent } from './components/data-table/data-table.component';
import { DataTableSortDirective } from './directives/data-table-sort.directive';
import { KeySearchComponent } from './components/key-search/key-search.component';
import { CardComponent } from './components/card/card.component';
import { StatusCardComponent } from './components/status-card/status-card.component';
import { DetailCardComponent } from './components/detail-card/detail-card.component';
import { WidgetGroupComponent } from './components/widget-group/widget-group.component';
import { CenterComponent } from './components/center/center.component';
import { ButtonIconComponent } from './components/button-icon/button-icon.component';
import { GoDetailComponent } from './components/go-detail/go-detail.component';
import { ImagePreviewComponent } from './components/image-preview/image-preview.component';
import { SwitchCheckboxComponent } from './components/switch-checkbox/switch-checkbox.component';
import { WizardStepperComponent } from './components/wizard-stepper/wizard-stepper.component';
import { PasswordStrengthComponent } from './components/password-strength/password-strength.component';
import { IptableEditComponent } from './components/iptable-edit/iptable-edit.component';
import { DataTableColumnDirective } from './directives/data-table-column.directive';
import { TreeComponent } from './components/tree/tree.component';
import { ApiDataTableComponent } from './components/api-data-table/api-data-table.component';
import { NavTabsComponent } from './components/nav-tabs/nav-tabs.component';
import { EchartsComponent } from './components/echarts/echarts.component';
import { ScriptInputComponent } from './components/script-input/script-input.component';
import { FetchPipe } from './pipes/fetch.pipe';

import { ZoneSelectInputComponent } from './components/zone-select-input/zone-select-input.component';
import { EnableStatusTextComponent } from './components/enable-status-text/enable-status-text.component';
import { UpdateStatusTextComponent } from './components/update-status-text/update-status-text.component';
import { OnlineStatusTextComponent } from './components/online-status-text/online-status-text.component';
import { UserTypeTextComponent } from './components/user-type-text/user-type-text.component';
import { AuthStatusTextComponent } from './components/auth-status-text/auth-status-text.component';
import { DetailRouterLinkDirective } from './directives/detail-router-link.directive';
import { DisplayStandbyComponent } from './components/display-standby/display-standby.component';
import { ScreensaverComponent } from './components/screensaver/screensaver.component';
import { AuthTypeComponent } from './components/auth-type/auth-type.component';
import { UserStatusTextComponent } from './components/user-status-text/user-status-text.component';
import { TaskStatusPipe } from './pipes/task-status.pipe';
import { MyDatePipe } from './pipes/date.pipe';
import { AssignPipe } from './pipes/assign.pipe';
import { EllipsisPipe } from './pipes/ellipsis.pipe';
import { BaseTreeComponent } from './components/base-tree/base-tree.component';
import { AddComponent } from './components/base-tree/add/add.component';
import { TreeListComponent } from './components/tree-list/tree-list.component';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { ApiErrorHandingInterceptor } from 'app/services/api-error-handing.interceptor';
import { XsrfInterceptor } from 'app/services/xsrf.interceptor';


const shareModules = [
  MatTooltipModule,
  NgbModule,
  PerfectScrollbarModule,
  MatIconModule,
  MatMenuModule,
  MatButtonModule,
  MatSliderModule,
  MatDialogModule,
  MatCheckboxModule,
  MatRadioModule,
  MatFormFieldModule,
  MatSelectModule,
  MatProgressSpinnerModule,
  MatTreeModule,
  FormsModule,
  ReactiveFormsModule,
];
const shareComponents = [
  TreeListComponent,
  AddComponent,
  BaseTreeComponent, //树组件
  NumberCardComponent, // 数字统计卡片
  DataTableComponent, // 数据表格
  DataTableColumnDirective, // 数据表格高级模式指令
  PaginationComponent, // 数据表格分页
  CheckboxComponent, // 数据表格多选框
  KeySearchComponent, // 关键字搜索
  CardComponent, // 基础卡片
  StatusCardComponent, // 区域状态卡片
  DetailCardComponent, // 详情卡片
  WidgetGroupComponent, // 卡片组
  CenterComponent, // 中心基础框架
  ButtonIconComponent, // 图表按钮
  GoDetailComponent, // 详情导航
  ImagePreviewComponent, // 图片预览
  SwitchCheckboxComponent, // 开关样式的单选组件
  WizardStepperComponent, // 步进列表组件
  PasswordStrengthComponent, // 密码强度配置
  IptableEditComponent, // iptable配置
  TreeComponent, // 树结构
  ApiDataTableComponent,
  NavTabsComponent, // 导航切换
  EchartsComponent, // 图表绘制组件
  ScriptInputComponent, // 脚本上传
  ZoneSelectInputComponent, // 区域选择组件
  EnableStatusTextComponent, // 区域资源冻结状态
  UpdateStatusTextComponent, // 终端和软件升级状态
  OnlineStatusTextComponent, // 终端和用户在线状态
  UserTypeTextComponent, //  终端用户类型
  UserStatusTextComponent, // 终端用户状态
  AuthStatusTextComponent, // 权限设置状态
  AuthTypeComponent, //权限设置类型
  DisplayStandbyComponent, // 显示器休眠
  ScreensaverComponent, // 屏幕保护
];

const shareDirectives = [DataTableSortDirective, DetailRouterLinkDirective, NoDblClickDirective];

const sharePipes = [SafePipe, RangePipe, FetchPipe, TaskStatusPipe, MyDatePipe, EllipsisPipe];

@NgModule({
  imports: [CommonModule, RouterModule, ...shareModules],
  exports: [...shareModules, ...shareComponents, ...sharePipes, ...shareDirectives],
  entryComponents: [
    AddComponent,
  ],
  providers:[
    {
      provide: HTTP_INTERCEPTORS,
      useClass: ApiErrorHandingInterceptor,
      multi: true,
    },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: XsrfInterceptor,
      multi: true,
    },
  ],
  declarations: [...shareComponents, ...sharePipes, ...shareDirectives, AssignPipe],
})
export class ShareModule { }
